/*
 * Copyright (C) 2014 Realtek Semiconductor Corp.
 * All Rights Reserved.
 *
 * This program is the proprietary software of Realtek Semiconductor
 * Corporation and/or its licensors, and only be used, duplicated,
 * modified or distributed under the authorized license from Realtek.
 *
 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
 *
 * Purpose : Definition of ME handler: UNI-G (264)
 *
 * Feature : The file includes the following modules and sub-modules
 *           (1) ME handler: UNI-G (264)
 */

#include "app_basic.h"


MIB_TABLE_INFO_T gMibUnigTableInfo;
MIB_ATTR_INFO_T  gMibUnigAttrInfo[MIB_TABLE_UNIG_ATTR_NUM];
MIB_TABLE_UNIG_T gMibUnigDefRow;
MIB_TABLE_OPER_T gMibUnigOper;


GOS_ERROR_CODE unig_drv_cfg_handler(void            *pOldRow,
                                    void            *pNewRow,
                                    MIB_OPERA_TYPE  operationType,
                                    MIB_ATTRS_SET   attrSet,
                                    UINT32          pri)
{
	/*
    TBD, handle Non-OMCI management identifier here!
     */

	return GOS_OK;
}

GOS_ERROR_CODE mibTable_init(MIB_TABLE_INDEX tableId)
{
    gMibUnigTableInfo.Name = "Unig";
    gMibUnigTableInfo.ShortName = "UNIG";
    gMibUnigTableInfo.Desc = "Uni-g";
    gMibUnigTableInfo.ClassId = (UINT32)(OMCI_ME_CLASS_UNI_G);
    gMibUnigTableInfo.InitType = (UINT32)(OMCI_ME_INIT_TYPE_ONU);
    gMibUnigTableInfo.StdType = (UINT32)(OMCI_ME_TYPE_STANDARD);
    gMibUnigTableInfo.ActionType = (UINT32)(OMCI_ME_ACTION_SET | OMCI_ME_ACTION_GET);
    gMibUnigTableInfo.pAttributes = &(gMibUnigAttrInfo[0]);
	gMibUnigTableInfo.attrNum = MIB_TABLE_UNIG_ATTR_NUM;
	gMibUnigTableInfo.entrySize = sizeof(MIB_TABLE_UNIG_T);
	gMibUnigTableInfo.pDefaultRow = &gMibUnigDefRow;

    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].Name = "EntityID";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Entity ID";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ENTITYID_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;

    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].Name = "CfgOptionStatus";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Configuration Option Status";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_CFGOPTIONSTATUS_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;

    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].Name = "AdminState";
	gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Administrative state";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_ADMINSTATE_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_MANDATORY;

    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].Name = "ManageCapability";
	gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Management capability";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT8;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].Len = 1;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_DEC;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_MANAGECAPABILITY_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;

	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].Name = "NonOmciPointer";
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Non-OMCI management identifier";
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].Len = 2;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
	gMibUnigAttrInfo[MIB_TABLE_UNIG_NONOMCIPOINTER_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;

	gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].Name = "RelayAgentOptions";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].Desc = "Relay agent options";
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].DataType = MIB_ATTR_TYPE_UINT16;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].Len = 2;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].IsIndex = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].MibSave = TRUE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].OutStyle = MIB_ATTR_OUT_HEX;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].OltAcc = OMCI_ME_ATTR_ACCESS_READ | OMCI_ME_ATTR_ACCESS_WRITE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].AvcFlag = FALSE;
    gMibUnigAttrInfo[MIB_TABLE_UNIG_RELAY_AGENT_OPTIONS_INDEX-MIB_TABLE_FIRST_INDEX].OptionType = OMCI_ME_ATTR_TYPE_OPTIONAL;

	memset(&(gMibUnigDefRow.EntityID), 0x00, sizeof(gMibUnigDefRow.EntityID));
	memset(&(gMibUnigDefRow.CfgOptionStatus), 0x00, sizeof(gMibUnigDefRow.CfgOptionStatus));
	gMibUnigDefRow.AdminState = OMCI_ME_ATTR_ADMIN_STATE_UNLOCK;
	gMibUnigDefRow.ManageCapability = UNIG_MGMT_CAPABILITY_BOTH_OMCI_NON_OMCI;
	memset(&(gMibUnigDefRow.NonOmciPointer), 0x00, sizeof(gMibUnigDefRow.NonOmciPointer));
	memset(&(gMibUnigDefRow.RelayAgentOptions), 0x00, sizeof(gMibUnigDefRow.RelayAgentOptions));

    memset(&gMibUnigOper, 0x0, sizeof(MIB_TABLE_OPER_T));
	gMibUnigOper.meOperDrvCfg = unig_drv_cfg_handler;
	gMibUnigOper.meOperConnCheck = NULL;
	gMibUnigOper.meOperDump = omci_mib_oper_dump_default_handler;
	gMibUnigOper.meOperConnCfg = NULL;

	MIB_TABLE_UNIG_INDEX = tableId;
	MIB_InfoRegister(tableId,&gMibUnigTableInfo,&gMibUnigOper);

    return GOS_OK;
}
